package hms.inventory;

/**
 * Vendor is an vendor.
 * 
 * @author Akilah McIntyre
 */
public class Vendor {
	/**
	 * unique identifier of an vendor
	 */
	public int vendor_id = -1;
	/**
	 * name of an vendor
	 */
	public String vendor_name = "";

	/**
	 * Constructs an vendor from an unique identifier and a name.
	 * 
	 * @param vendorID
	 *            unique identifier of an vendor
	 * @param vendorName
	 *            name of of an vendor
	 * 
	 **/
	public Vendor(int vendorID, String vendorName) {
		this.vendor_id = vendorID;
		this.vendor_name = vendorName;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + vendor_id;
		result = prime * result
				+ ((vendor_name == null) ? 0 : vendor_name.hashCode());
		return result;
	}

	/**
	 * Compares two vendors for equality. The result is true if and only if the
	 * argument is not null and if a Vendor object has the same unique
	 * identifier and name as this object.
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof Vendor)) {
			return false;
		}
		Vendor other = (Vendor) obj;
		if (vendor_id != other.vendor_id) {
			return false;
		}
		if (vendor_name == null) {
			if (other.vendor_name != null) {
				return false;
			}
		} else if (!vendor_name.equals(other.vendor_name)) {
			return false;
		}
		return true;
	}

	/**
	 * Returns a string representation of this Vendor, which is vendor_name
	 **/
	public String toString() {
		return vendor_name;
	}

}